package com.polaris.live.adapter.gift

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterGiftIndicatorBinding

/**
 * GiftIndicatorAdapter
 *
 * @author Created by 半仙 on 2023/9/19/019 9:37
 */
class GiftIndicatorAdapter : BaseBindingAdapter<AdapterGiftIndicatorBinding, String>() {

    private var selectPosition = 0

    override fun convert(holder: VBViewHolder<AdapterGiftIndicatorBinding>, item: String) {
        holder.vb.apply {
            val position = holder.absoluteAdapterPosition
            if (selectPosition == position) {
                itemLongInclndicator.visibility = View.VISIBLE
                itemInclndicator.visibility = View.GONE
            } else {
                itemLongInclndicator.visibility = View.GONE
                itemInclndicator.visibility = View.VISIBLE
            }
        }
    }

    fun setSelect(position: Int) {
        selectPosition = position
        notifyDataSetChanged()
    }
}